package com.qf.servlet;

import com.qf.entity.Student;
import com.qf.service.StuService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * description:
 * author: Ken
 * 公众号：Java架构栈
 */
@WebServlet(urlPatterns = "/stuquery")
public class StuQueryServlet extends HttpServlet {

    private StuService stuService = new StuService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //调用service层
        List<Student> stus = stuService.queryStus();
        req.setAttribute("stus", stus);
        //转发到学生列表页
        req.getRequestDispatcher("stulist.jsp").forward(req, resp);
    }
}
